/*
 * EquilibriumConstant.h
 *
 *  Created on: 31 Jul 2011
 *      Author: Allan
 */

#ifndef EQUILIBRIUMCONSTANT_H_
#define EQUILIBRIUMCONSTANT_H_

// C++ includes
#include <functional>
#include <vector>
using namespace std;

// GeoReact includes
#include "Numerics/LagrangeInterpolator.h"

class EquilibriumConstant
{
public:
	typedef std::function<const double(double T, double P)>
	Function;
	
public:
	EquilibriumConstant();
	
	EquilibriumConstant(double logK);
	
	EquilibriumConstant(double logK, double T);
	
	EquilibriumConstant(const vector<double>& logKi, const vector<double>& Ti);
	
	EquilibriumConstant(const Function& K);
	
	void
	GetData(vector<double>& logKi, vector<double>& Ti) const;
	
	const Function
	GetFunction() const;
	
	const double
	operator()(double T, double P) const;
	
private:
	/// The equilibrium constants (logKi) for the temperature points (Ti)
	vector<double> logKi, Ti;
	
	/// The Lagrange interpolator instance responsible to interpolate the equilibrium constants
	LagrangeInterpolator li;
	
	/// The equilibrium constant function
	Function K;
	
	/// The boolean variable that is used to query if the equilibrium constant function is known
	bool knownfunction;
};

#endif /* EQUILIBRIUMCONSTANT_H_ */
